package cn.victory._02_redisClient;

import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.cluster.RedisClusterClient;
import org.junit.Test;

/**
 * @ Description TODO
 * @ Author victory
 * @ Date 2022/6/29
 **/
public class RedisClientDemo {
    @Test
    public void testRedisClient(){
        //创建普通客户端
        RedisURI redisUri = RedisURI.builder().withHost("localhost").withPort(6379).build();
        RedisClient redisClient = RedisClient.create(redisUri);

        //关闭客户端
        redisClient.shutdown();
    }


    @Test
    public void testRedisClusterClient(){
        //Redis创建集群客户端一：
        RedisURI redisUri6379 = RedisURI.builder().withHost("localhost").withPort(6379).build();
        RedisClusterClient redisClusterClient79 = RedisClusterClient.create(redisUri6379);

        //Redis创建集群客户端二：
        RedisURI redisUri6380 = RedisURI.builder().withHost("localhost").withPort(6380).build();
        RedisClusterClient redisClusterClient80 = RedisClusterClient.create(redisUri6380);

        //关闭客户端
        redisClusterClient79.shutdown();
        redisClusterClient80.shutdown();
    }
}
